home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7835 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  43 lines

  1. Path: charnel.ecst.csuchico.edu!mcelroy
  2. From: mcelroy@ecst.csuchico.edu (James Robert McElroy)
  3. Newsgroups: comp.lang.c++
  4. Subject: Initializing pointers in MIL???
  5. Date: 19 Feb 1996 17:52:27 GMT
  6. Organization: California State University, Chico
  7. Message-ID: <4gadcr$oqf@charnel.ecst.csuchico.edu>
  8. NNTP-Posting-Host: hairball.ecst.csuchico.edu
  9.  
  10. Presented below is a code segment that works on
  11. the Borland compiler but fails on a Sun compiler.
  12. The code in question deals with initializing a
  13. pointer to an object in the MIL using "new" in the
  14. foo constructor. 
  15.  
  16. The constructor is placed inline for ease of
  17. demonstrating the problem, but it works (or fails)
  18. regarless of whether it is inline.
  19.  
  20. I am wondering if the ARM covers this, and if
  21. it is legal C++ syntax:
  22.  
  23.  
  24. class fubar {
  25.    private:
  26.       int x;
  27.    public:
  28.       fubar(int anX): x(anX) { }  // no, not here
  29. };
  30.  
  31. class foo {
  32.    private:
  33.       fubar * pf;
  34.    public:
  35.       foo(int anInt): pf ( new fubar(anInt)) { } // here!!!
  36. };
  37.  
  38.  
  39. -- 
  40. Jim McElroy
  41. Calif. State Univ., Chico
  42. mcelroy@ecst.csuchico.edu
  43.